<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>{$tpshop_config.basic_store_title|default='我的商城'}商家登录</title>
  <link rel="shortcut icon" type="image/x-icon" href="{$tpshop_config.basic_store_ico|default='/public/static/images/storeico.png'}" media="screen"/>
<meta name="author" content="yinqi">
  <link href="__ADMIN__/css/bootstrap.min.css" rel="stylesheet">
  <link href="__ADMIN__/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="__ADMIN__/css/style.css" rel="stylesheet">
  <link href="__ADMIN__/css/custom.css" rel="stylesheet">
<style>
  .logo{
    max-width: 200px;
  }
.lyear-wrapper {
    position: relative;
}
.lyear-login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
}
.login-center {
    background: #fff;
    min-width: 38.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em 0;
}
.login-header {
    margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
}
  .captcha{
    width: 120px;
  }
</style>
</head>
<body>
<div class="row lyear-wrapper">
  <div class="lyear-login">
    <div class="login-center">
      <div class="login-header text-center">
        <a href="javascript:;"> <img class="logo" src="{$tpshop_config.basic_dianpu_home_logo}"> </a>
      </div>
      <form action="#!" method="post">
        <div class="form-group has-feedback feedback-left">
          <input type="text" placeholder="请输入您的登录账号" class="form-control" name="mobile" id="username" />
          <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
          <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left row">
          <div class="col-xs-7">
            <input type="text" name="captcha" class="form-control" placeholder="请输入验证码">
            <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="col-xs-5">
            <img src="{:url('Index/verify')}" class="pull-right captcha" id="captcha" style="cursor: pointer;" onclick="this.src=this.src+'?d='+Math.random();" title="点击刷新" alt="captcha">
          </div>
        </div>
        <div class="form-group">
          <button class="btn btn-block btn-theme" type="button">立即登录</button>
        </div>
      </form>
    </div>
  </div>
</div>
<script src="__STATIC__/js/jquery.js"></script>
<script src="__STATIC__/js/vue.js"></script>
<link rel="stylesheet" type="text/css" href="__ADMIN__/plugin/TGTool/TGTool.css" />
<script src="__ADMIN__/plugin/TGTool/TGTool.js"></script>
<script type="text/javascript">
  $('.btn-theme').click(function () {
    var mobile=$('[name=mobile]').val();
    var password=$('[name=password]').val();
    var captcha=$('[name=captcha]').val();
    if (mobile==''){
      showErrorMsg("登录账号不能为空");
      return;
    }
    if (password==''){
        showErrorMsg("密码不能为空");
      return;
    }
    if (captcha==''){
        showErrorMsg("验证码不能为空");
      return;
    }
    $.ajax({
      url:"{:url('Admin/login')}",
      data:{'mobile':mobile,'password':password,'captcha':captcha},
      type:'post',
      dataType:'json',
      success:function(result){
        if (result.code==1){
          showSuccessMsg(result.msg,function () {
            location.href=result.data.url;
          })
        }else if(result.code==10){
          var src=$('#captcha').attr('src');
          $('#captcha').attr('src',src+'?d='+Math.random());
            showErrorMsg(result.msg);
        }else {
            showErrorMsg(result.msg);
        }
      },
      error : function(XMLHttpRequest, textStatus, errorThrown) {
          showErrorMsg("网络失败，请刷新页面后重试!");
      }
    });
  });
  function showErrorMsg(msg,callback=function () {}) {
      var tg = TGTool();
      tg.error(msg,callback);
  }
  function showSuccessMsg(msg,callback=function () {}) {
      var tg = TGTool();
      tg.success(msg,callback);
  }
</script>
</body>
</html>
